import api from '../../api';
import { message } from 'antd';

export default {
  namespace: 'SplitPipelineQueryM',

  state: {
    tableData: { columns: [], dataSource: [] },
  },

  effects: {
    //查询真实交易流水
    *queryTableListReal({ payload, callback }, { call, put }) {
      const response = yield call(api.splitPositionQuery.queryTableListReal, payload);
      if (response) {
        if (response.code == 0) {
          callback('success', response.data);
        } else {
          callback('fail');
          message.error(response.msg || '查询真实交易流水失败!');
        }
      } else {
        callback('fail');
        message.error('查询真实交易流水失败!');
      }
    },
    //  //查询拆分交易列表
    *queryTableListAdjust({ payload, callback }, { call, put }) {
      const response = yield call(api.splitPositionQuery.queryTableListAdjust, payload);
      if (response) {
        if (response.code == 0) {
          callback('success', response.data);
        } else {
          callback('fail');
          message.error(response.msg || '查询拆分交易流水失败!');
        }
      } else {
        callback('fail');
        message.error('查询拆分交易流水失败!');
      }
    },
  },

  reducers: {
    save(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
  },
};
